#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>

int main(){
	char buf[10];
	scanf("%10s", buf);

	int res = 0;
	int t = 1;

	int i = strlen(buf);
	while (i-- > 0) {
		res += (buf[i] - 'A') * t;
		t *= 26;
	}

	printf("%d", res);
};